package com.test.javase;

import java.time.LocalDate;
import java.time.Month;
import java.util.Scanner;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/5/17
 * 3.使用LocalDate类，输入任意一个年份，得到这年的2月份有几天？
 */
public class FebruaryDays {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入年份: ");
        int year = scanner.nextInt();
        int daysInFebruary = getDaysInFebruary(year);
        System.out.println(year + "年的2月份有 " + daysInFebruary + " 天");
        scanner.close();
    }
    public static int getDaysInFebruary(int year) {
        LocalDate marchFirst = LocalDate.of(year, Month.MARCH, 1);
        LocalDate lastDayOfFebruary = marchFirst.minusDays(1);
        return lastDayOfFebruary.getDayOfMonth();
    }
}
